//
//  BarButtonItems+extnsion.swift
//  个人微博
//
//  Created by 任聪聪 on 2017/5/26.
//  Copyright © 2017年 任孜聪. All rights reserved.
//

import UIKit


extension UIBarButtonItem {
    convenience init(title:String,font:CGFloat = 16,any:AnyObject,action:Selector,isBack:Bool = false) {
        //便利构造函数想要使用控件的属性先要进行对其进行初始化
        let bn:UIButton = UIButton.cz_textButton(title, fontSize: font, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack{
            let imageName = "navigationbar_back_withtext"
            let imageNameHight = "navigationbar_back_withtext_highlighted"
            bn.setImage(UIImage.init(named: imageName), for: .normal)
            bn.setImage(UIImage.init(named: imageNameHight), for: .highlighted
            )
            bn.sizeToFit()
        }
        bn.addTarget(any, action:action, for: .touchUpInside)
        self.init(customView: bn)
    }
}
